<?php
 /* 处理上传 */
  if ($_POST)
  {
	$cal_zh_name = work_str($_POST["cal_zh_name"]);			//单位类型中文名称
	$cal_en_name = work_str($_POST["cal_en_name"]);			//单位类型英文名称
	$cal_other_name = work_str($_POST["cal_other_name"]);	//单位类型其他语言名称
	$cal_order = work_str($_POST["cal_order"]);				//单位类型顺序
    $cal_id = work_str($_POST['cal_id']);
	
	if($cal_id>'0')
	{
		$query = "UPDATE $TBL_CALIG SET cal_zh_name='$cal_zh_name',cal_en_name='$cal_en_name',cal_other_name='$cal_other_name',cal_order='$cal_order' WHERE cal_id='$cal_id'";
	}
	else
	{
		$query = "INSERT INTO $TBL_CALIG SET cal_zh_name='$cal_zh_name',cal_en_name='$cal_en_name',cal_other_name='$cal_other_name',cal_order='$cal_order'";
	}
	$res = mysql_query($query);
	if (! $res)
	{
	   MyNotice("插入数据库出错,请与管理员联系",2,"calling.php");
	   exit(0);
	}
	MyNotice("数据录入成功",2,"calling.php");
	exit(0);
  }
  $tpl -> set_file(array("page" => "add_calling.htm"));
  //当为修改时
  if($cal_id=(int)$_GET['id'])
  {
	  $query = "SELECT * FROM $TBL_CALIG WHERE cal_id='$cal_id'";
	  $result = mysql_query( $query) or die(mysql_error());
	  $array = mysql_fetch_array( $result);
	  $tpl->set_var($array);
  }
  $frm_name=($cal_id>'0')?"修改行业":"添加行业";
  $tpl -> set_var( "frm_name",$frm_name);
  $tpl -> parse("Output","page");
  $tpl -> p("Output");
  exit(0);
?>